from concurrent.futures import ThreadPoolExecutor, as_completed
from sqlalchemy import create_engine


class CustomThreadPool:
    __executor = ThreadPoolExecutor(max_workers=5)

    @staticmethod
    def get_pool():
        return CustomThreadPool.__executor


class CustomDbEngines:
    """
        不同数据源的链接字符串不同 engine_str
    """
    engines = {}

    @staticmethod
    def get_engine(engine_str):
        if CustomDbEngines.engines.get(engine_str) is None:
            CustomDbEngines.engines[engine_str] = create_engine(engine_str, encoding='utf-8')

        return CustomDbEngines.engines[engine_str]
